package com.igeek.d0607;

import java.io.*;
import java.lang.invoke.VarHandle;

/**
 * @Author: zhiyu
 * @Date:18:19
 * @DESC:
 */
public class Test3 {
    public static void readUtf8(){
        String path = Test2.class.getResource("").getPath();
        String filename = path.substring(1)+"UTF8.txt";
        String filename1 = path.substring(1)+"GBK.txt";
        try (
                BufferedReader br =
                        new BufferedReader(
                                new InputStreamReader(
                                        new FileInputStream(filename)));
                BufferedWriter bw =
                        new BufferedWriter(
                                new OutputStreamWriter(
                                        new FileOutputStream(filename1),"GBK"));
                PrintWriter pw = new PrintWriter(bw);

        ){
            String s = "";
            while ((s=br.readLine())!=null){
                if (!s.startsWith("//")){
                    pw.println(s);
                    pw.flush();
                }else {
                    continue;
                }
            }
             }catch (Exception e){
                 e.printStackTrace();
             }
    }

    public static void main(String[] args) {
        readUtf8();
    }
}
